Skip to main content

Compiler Support

GPBT detects the active C++ compiler and applies a corresponding set of flags across all four build configurations. Detection uses CMAKE_CXX_COMPILER_ID and maps to a consistent token stored in GPBT_CURRENT_COMPILER.

Supported compilers

CompilerGPBT_CURRENT_COMPILERMinimum versionNotes
MSVC (Visual C++)MSVCVS 2022 17.xRequired for C++23 support
Clang-CL (Windows)Clang-CL17.0Clang with MSVC frontend
ClangClang17.0Includes Apple Clang on macOS and iOS
GCCGCC13.0Required for C++23 feature completeness

Compiler detection and override

GPBT detects the compiler automatically. The token is available at configure time:

cmake -S . -B build
# GPBT_CURRENT_COMPILER is now set to "MSVC", "Clang-CL", "Clang", or "GCC"

Flags applied per compiler

GPBT applies different sets of flags depending on the active compiler and configuration. The tables below show the key flags. These are applied to every target automatically.

MSVC

ConfigurationKey flags
All/W4, /WX, /permissive-, /Zc:__cplusplus, /EHsc, /GS, /Gy, /GF
Debug/Od, /Zi, /RTC1, /sdl
Development/O2, /Zi
Profile/O2, /Zi, /Oy-
Shipping/O2, /Ob3, /GL (WPO), /Gw, /GS-

Clang-CL (Windows)

ConfigurationKey flags
All/W4, /WX, /permissive-, -Wextra, /Zc:__cplusplus, /EHsc, /GS, /Gy, /GF, /Oy-
Debug/Od, /Zi, -fstack-protector-strong
Development/O2, /Zi
Profile/O2, /Zi
Shipping/O2, /GL (WPO), /Gw, -flto=thin

Clang

ConfigurationKey flags
All-Wall, -Wextra, -Werror, -fvisibility=hidden, -ffunction-sections, -fdata-sections
Debug-O0, -g3, -fno-omit-frame-pointer, -fstack-protector-strong
Development-O2, -g, -fno-omit-frame-pointer
Profile-O3, -g, -fno-omit-frame-pointer, -fno-inline-functions
Shipping-O3, -ffast-math, -flto=thin, -fwhole-program-vtables

GCC

ConfigurationKey flags
All-Wall, -Wextra, -Werror, -fvisibility=hidden, -ffunction-sections, -fdata-sections
Debug-O0, -g3, -fno-omit-frame-pointer, -fstack-protector-strong
Development-O2, -g, -fno-omit-frame-pointer
Profile-O3, -g, -fno-omit-frame-pointer, -fno-inline-functions-called-once
Shipping-O3, -ffast-math, -flto=auto, -fno-semantic-interposition

C++ standard

GPBT enforces C++23 globally through gpApplyGraphicalPlaygroundDefaultPolicy(). Compiler extensions are disabled (CMAKE_CXX_EXTENSIONS OFF) to ensure strictly conforming code.

Strict warnings

All targets compile with strict warnings and warnings-as-errors enabled by default. To turn this off for a specific target (typically thirdparty code or legacy modules), use gpDisableStrictWarnings(). See Miscellaneous Options for details.

LTO is applied in the Shipping configuration only. The strategy depends on the compiler:

  • Clang: Thin LTO (-flto=thin). Faster link times than full LTO with most of the optimisation benefit.
  • GCC: Full LTO (-flto=auto). More aggressive, slower to link.
  • MSVC: Whole Program Optimisation (/GL compile, /LTCG link).

The LTO compile flag is passed to the linker via an internal property so the linker policy file always matches the compile-time setting.